/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cardgame.game;

import cardgame.network.BitInputStream;
import cardgame.network.BitOutputStream;
import java.io.IOException;

/**
 *
 * @author Carl
 */
public class SimpleManaCard extends Card implements ManaProvider{

    protected SimpleManaCard(Mana mana, int amount){
        this.mana = mana;
        manaAmount.add(mana, amount);
        initialize();
    }
    private Mana mana;
    private ManaAmount manaAmount = new ManaAmount();
    
    private void initialize(){
        int amount = 0;
        for(Mana mana : Mana.values()){
            amount = manaAmount.getMana(mana);
            if(amount > 0){
                break;
            }
        }
        description = new Description("Mana" + ((amount > 1)?" (" + amount + "x " + mana.toString().toUpperCase().substring(0, 1) + mana.toString().toLowerCase().substring(1) + ")":""), "");
        manaTypes = new Mana[]{mana};
    }

    public Mana getMana(){
        return mana;
    }
    
    @Override
    public ManaAmount getProvidedMana(){
        return manaAmount;
    }

    @Override
    public void provide(){
        tap();
    }

    @Override
    public boolean isAvailable(){
        return (!isTapped());
    }

    @Override
    public void write(BitOutputStream outputStream){
        super.write(outputStream);
        /*outputStream.writeEnum(mana);
        manaAmount.write(outputStream);*/
    }

    @Override
    public void read(BitInputStream inputStream) throws IOException{
        super.read(inputStream);
        /*mana = inputStream.readEnum(Mana.class);
        manaAmount.read(inputStream);
        initialize();*/
    }
}
